home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- # Include the cgi library from chapter 1.
-
- require "cgilib.pl";
-
- # Initialize some variables
-
- $data = "";
- %cgiDict;
- $theScript = "";
-
- #Read the cgi input
-
- &readData(*data);
- &parseData(*data,*cgiDict);
-
- # Figure out which button was selected
-
- if($cgiDict{"choice"} eq "vars")
- {
- $theScript = "envvar.pl";
- }
- elsif($cgiDict{"choice"} eq "formdata")
- {
- $theScript = "formdata.pl";
- }
- else
- {
- $theScript = "fortune.sh";
- }
-
- # Rest the environment
-
- $ENV{"CONTENT_LENGTH"} = length($data);
- $ENV{"REQUEST_METHOD"} = "POST";
-
- if(open(childPipe,"|-"))
- {
- # We are the parent
- #Write the CGI data to the child
- print childPipe $data;
- close(childPipe);
- }
- else
- {
- #We are the child
- #Try to execute the other program
- exec($theScript);
-
- die "Exec failed.\n";
- }
-
- 1;
-
-